<!doctype html>
<html lang="en">
<head>
    <title>Code coverage report for components/MarkdownEditor/index.vue</title>
    <meta charset="utf-8" />
    <link rel="stylesheet" href="../../prettify.css" />
    <link rel="stylesheet" href="../../base.css" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style type='text/css'>
        .coverage-summary .sorter {
            background-image: url(../../sort-arrow-sprite.png);
        }
    </style>
</head>
<body>
<div class='wrapper'>
  <div class='pad1'>
    <h1>
      <a href="../../index.html">All files</a> / <a href="index.html">components/MarkdownEditor</a> index.vue
    </h1>
    <div class='clearfix'>
      <div class='fl pad1y space-right2'>
        <span class="strong">0% </span>
        <span class="quiet">Statements</span>
        <span class='fraction'>0/58</span>
      </div>
      <div class='fl pad1y space-right2'>
        <span class="strong">0% </span>
        <span class="quiet">Branches</span>
        <span class='fraction'>0/26</span>
      </div>
      <div class='fl pad1y space-right2'>
        <span class="strong">0% </span>
        <span class="quiet">Functions</span>
        <span class='fraction'>0/17</span>
      </div>
      <div class='fl pad1y space-right2'>
        <span class="strong">0% </span>
        <span class="quiet">Lines</span>
        <span class='fraction'>0/57</span>
      </div>
    </div>
  </div>
  <div class='status-line low'></div>
<pre><table class="coverage">
<tr><td class="line-count quiet">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129</td><td class="line-coverage quiet"><span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span></td><td class="text"><pre class="prettyprint lang-js">&lt;template&gt;
  &lt;div :id="id" /&gt;
&lt;/template&gt;
&nbsp;
&lt;script lang="ts"&gt;
<span class="cstat-no" title="statement not covered" >import 'codemirror/lib/codemirror.css' // codemirror</span>
<span class="cstat-no" title="statement not covered" >import 'tui-editor/dist/tui-editor.css' // editor ui</span>
<span class="cstat-no" title="statement not covered" >import 'tui-editor/dist/tui-editor-contents.css' // editor content</span>
<span class="cstat-no" title="statement not covered" >import { Component, Prop, Vue, Watch } from 'vue-property-decorator'</span>
<span class="cstat-no" title="statement not covered" >import defaultOptions from './default-options'</span>
<span class="cstat-no" title="statement not covered" >import TuiEditor from 'tui-editor'</span>
&nbsp;
<span class="cstat-no" title="statement not covered" ><span class="fstat-no" title="function not covered" >const defaultId = () =&gt; 'markdown-editor-' + +new Date() + ((Math.random() * 1000).toFixed(0) + '')</span></span>
&nbsp;
@Component({
  name: 'MarkdownEditor'
})
<span class="cstat-no" title="statement not covered" ><span class="cstat-no" title="statement not covered" >export default class extends Vue {</span></span>
<span class="cstat-no" title="statement not covered" >  @Prop({ required: true }) private value!: string</span>
<span class="cstat-no" title="statement not covered" >  @Prop({ default: defaultId }) private id!: string</span>
<span class="cstat-no" title="statement not covered" ><span class="fstat-no" title="function not covered" >  @Prop({ default: () =&gt; defaultOptions }) private options!: tuiEditor.IEditorOptions</span></span>
<span class="cstat-no" title="statement not covered" >  @Prop({ default: 'markdown' }) private mode!: string</span>
<span class="cstat-no" title="statement not covered" >  @Prop({ default: '300px' }) private height!: string</span>
  // https://github.com/nhnent/tui.editor/tree/master/src/js/langs
<span class="cstat-no" title="statement not covered" >  @Prop({ default: 'en_US' }) private language!: string</span>
&nbsp;
  private markdownEditor?: tuiEditor.Editor
&nbsp;
<span class="fstat-no" title="function not covered" >  get editorOptions() {</span>
<span class="cstat-no" title="statement not covered" >    const options = Object.assign({}, defaultOptions, this.options)</span>
<span class="cstat-no" title="statement not covered" >    options.initialEditType = this.mode</span>
<span class="cstat-no" title="statement not covered" >    options.height = this.height</span>
<span class="cstat-no" title="statement not covered" >    options.language = this.language</span>
<span class="cstat-no" title="statement not covered" >    return options</span>
  }
&nbsp;
  @Watch('value')
<span class="cstat-no" title="statement not covered" ><span class="fstat-no" title="function not covered" >  private onValueChange(value: string, oldValue: string) {</span></span>
<span class="cstat-no" title="statement not covered" >    if (this.markdownEditor) {</span>
<span class="cstat-no" title="statement not covered" >      if (value !== oldValue &amp;&amp; value !== this.markdownEditor.getValue()) {</span>
<span class="cstat-no" title="statement not covered" >        this.markdownEditor.setValue(value)</span>
      }
    }
  }
&nbsp;
  @Watch('language')
<span class="cstat-no" title="statement not covered" ><span class="fstat-no" title="function not covered" >  private onLanguageChange() {</span></span>
<span class="cstat-no" title="statement not covered" >    this.destroyEditor()</span>
<span class="cstat-no" title="statement not covered" >    this.initEditor()</span>
  }
&nbsp;
  @Watch('height')
<span class="cstat-no" title="statement not covered" ><span class="fstat-no" title="function not covered" >  private onHeightChange(value: string) {</span></span>
<span class="cstat-no" title="statement not covered" >    if (this.markdownEditor) {</span>
<span class="cstat-no" title="statement not covered" >      this.markdownEditor.height(value)</span>
    }
  }
&nbsp;
  @Watch('mode')
<span class="cstat-no" title="statement not covered" ><span class="fstat-no" title="function not covered" >  private onModeChange(value: string) {</span></span>
<span class="cstat-no" title="statement not covered" >    if (this.markdownEditor) {</span>
<span class="cstat-no" title="statement not covered" >      this.markdownEditor.changeMode(value)</span>
    }
  }
&nbsp;
<span class="fstat-no" title="function not covered" >  mounted() {</span>
<span class="cstat-no" title="statement not covered" >    this.initEditor()</span>
  }
&nbsp;
<span class="fstat-no" title="function not covered" >  destroyed() {</span>
<span class="cstat-no" title="statement not covered" >    this.destroyEditor()</span>
  }
&nbsp;
<span class="fstat-no" title="function not covered" >  private initEditor() {</span>
<span class="cstat-no" title="statement not covered" >    const editorElement = document.getElementById(this.id)</span>
<span class="cstat-no" title="statement not covered" >    if (!editorElement) return</span>
<span class="cstat-no" title="statement not covered" >    this.markdownEditor = new TuiEditor({</span>
      el: editorElement,
      ...this.editorOptions
    })
<span class="cstat-no" title="statement not covered" >    if (this.value) {</span>
<span class="cstat-no" title="statement not covered" >      this.markdownEditor.setValue(this.value)</span>
    }
<span class="cstat-no" title="statement not covered" ><span class="fstat-no" title="function not covered" >    this.markdownEditor.on('change', () =&gt; {</span></span>
<span class="cstat-no" title="statement not covered" >      this.$emit('input', this.markdownEditor!.getValue())</span>
    })
  }
&nbsp;
<span class="fstat-no" title="function not covered" >  private destroyEditor() {</span>
<span class="cstat-no" title="statement not covered" >    if (!this.markdownEditor) return</span>
<span class="cstat-no" title="statement not covered" >    this.markdownEditor.off('change')</span>
<span class="cstat-no" title="statement not covered" >    this.markdownEditor.remove()</span>
<span class="cstat-no" title="statement not covered" >    this.markdownEditor = undefined</span>
  }
&nbsp;
<span class="fstat-no" title="function not covered" >  public focus() {</span>
<span class="cstat-no" title="statement not covered" >    if (this.markdownEditor) {</span>
<span class="cstat-no" title="statement not covered" >      this.markdownEditor.focus()</span>
    }
  }
&nbsp;
<span class="fstat-no" title="function not covered" >  public setValue(value: string) {</span>
<span class="cstat-no" title="statement not covered" >    if (this.markdownEditor) {</span>
<span class="cstat-no" title="statement not covered" >      this.markdownEditor.setValue(value)</span>
    }
  }
&nbsp;
<span class="fstat-no" title="function not covered" >  public getValue() {</span>
<span class="cstat-no" title="statement not covered" >    if (this.markdownEditor) {</span>
<span class="cstat-no" title="statement not covered" >      return this.markdownEditor.getValue()</span>
    }
<span class="cstat-no" title="statement not covered" >    return ''</span>
  }
&nbsp;
<span class="fstat-no" title="function not covered" >  public setHtml(value: string) {</span>
<span class="cstat-no" title="statement not covered" >    if (this.markdownEditor) {</span>
<span class="cstat-no" title="statement not covered" >      this.markdownEditor.setHtml(value)</span>
    }
  }
&nbsp;
<span class="fstat-no" title="function not covered" >  public getHtml() {</span>
<span class="cstat-no" title="statement not covered" >    if (this.markdownEditor) {</span>
<span class="cstat-no" title="statement not covered" >      return this.markdownEditor.getHtml()</span>
    }
<span class="cstat-no" title="statement not covered" >    return ''</span>
  }
}
&lt;/script&gt;
&nbsp;</pre></td></tr>
</table></pre>
<div class='push'></div><!-- for sticky footer -->
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
  Code coverage
  generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Mon Aug 05 2019 17:01:25 GMT+0800 (GMT+08:00)
</div>
</div>
<script src="../../prettify.js"></script>
<script>
window.onload = function () {
        if (typeof prettyPrint === 'function') {
            prettyPrint();
        }
};
</script>
<script src="../../sorter.js"></script>
</body>
</html>
